package com.runen.infinitemovement.steputil;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.util.Log;

import com.runen.infinitemovement.service.LocationService;
import com.runen.rxnetlibrary.utils.AppUtils;
import com.runen.rxnetlibrary.utils.LogUtil;

/**
 * @ClassName: StepScreenReceiver
 * @Description: 解锁亮屏广播
 * @Author: yanxu5
 * @Date: 2019/8/19
 */
public class SportsIsPauseReceiver extends BroadcastReceiver {
    private boolean isPause;

    @Override
    public void onReceive(Context context, Intent intent) {
        if (null != intent.getAction()) {
            if (intent.getAction().equals("ACTION_PAUSE")) {
                isPause = true;
                LogUtil.e("ACTION_PAUSE","zoe");
            }
            if (intent.getAction().equals("ACTION_NO_PAUSE")) {
                isPause = false;
                LogUtil.e("ACTION_PAUSE","zoulw");
            }
            try {
                Intent todayStepIntent = new Intent(context, LocationService.class);
                todayStepIntent.putExtra("IS_PAUSE", isPause);
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                    context.startForegroundService(todayStepIntent);
                } else {
                    context.startService(todayStepIntent);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

}
